<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="header">
        <Top></Top>
      </div>
      <div class="content">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <MapBox class="map"></MapBox>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Couter class="count"></Couter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, ref, onMounted, useTemplateRef } from 'vue'
import Top from './components/Top.vue'
import Tourist from './components/Tourist.vue'
import Sex from './components/Sex.vue'
import Age from './components/Age.vue'
import MapBox from './components/MapBox.vue'
import Line from './components/Line.vue'
import Rank from './components/Rank.vue'
import Year from './components/Year.vue'
import Couter from './components/Couter.vue'

let screen = useTemplateRef<any>('screen')

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})

window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}

function getScale(w = 1920, h = 1080) {
  let ww = window.innerWidth / w
  let wh = window.innerHeight / h
  return Math.min(ww, wh)
}
</script>
<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .header {
      width: 100%;
      height: 40px;
    }
    .content {
      display: flex;
      .left {
        flex: 0.9;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1.2;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }
      .center {
        flex: 1.7;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0 20px;
        .map {
          flex: 4;
        }

        .line {
          flex: 1;
        }
      }
      .right {
        flex: 0.9;
        display: flex;
        flex-direction: column;
        .rank {
          flex: 1.2;
        }

        .year {
          flex: 1;
        }

        .count {
          flex: 1;
        }
      }
    }
  }
}
</style>
